package com.zengzhi.mydesignmode.observermode;

/**
 * @author xiejiawei
 * @Date 2021-08-16
 * @Time 21:53
 * 当前天气状态的布告版
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {

    private float temperature;
    private float humidity;
    private float pressure;
    private Subject weatherData;
    public CurrentConditionsDisplay(Subject weatherData){
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }
    /**
     * 显示的方法
     */
    @Override
    public void disPlay() {
        System.out.println("Current Conditions:"  + temperature
        + "F degrees and" + humidity +"% humidity:"+pressure);
    }

    /**
     * 更新的接口
     *
     * @param temperature     温度
     * @param humidity 湿度
     * @param pressure 压力
     */
    @Override
    public void update(float temperature, float humidity, float pressure) {
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        disPlay();
    }
}
